using UnityEngine;
using System;

public class MBattleUIWidgetInfoCtrl : BattleUIWidgetInfoController
{
    

    protected override void Start()
    {
        base.Start();

        if (playerUiPref)
            playerUiPref.gameObject.SetActive(false);
    }


    public Transform playerInfoParent;

    public PlayerInfo playerUiPref;
    public PlayerInfo ShowPlayerInfo(RoleEntity role, float healthValue,Func<Vector3,Vector3,Vector3> WorldPosToUICameraPos,Vector3 offset = new Vector3())
    {
        if (!this) return null;

        int value = (int)(healthValue * 10);
        healthValue = value / 10f;

        var item = ShowObject<PlayerInfo>(role.GetHashCode().ToString(), null, playerUiPref.gameObject, playerInfoParent);// Instantiate<PlayerInfo>(playerUiPref, playerInfoParent);
        item.gameObject.SetActive(true);
        item.Init(healthValue, role.transform, WorldPosToUICameraPos, offset);
        return item;
    }
    public void HidePlayerInfo(RoleEntity role)
    {
        this.HideObject<PlayerInfo>(role.GetHashCode().ToString());
    }

}